package com.xiaoma.tpo.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.WdPlan;
import com.xiaoma.tpo.dto.WdPlanVo;

@Repository
public class WdPlanDao extends BaseDaoImpl<WdPlan>{

    
    private static final Logger LOG = LoggerFactory.getLogger(WdPlanDao.class);
    
    @SuppressWarnings("unchecked")
    public List<WdPlanVo> findAllWordPlans(){
        String sql = "select a.*, count(b.wd_plan_id) group_count from wd_plan a left join wd_group b on a.id = b.wd_plan_id group by a.id;";
        LOG.info("SQL:{}", sql);
        List<?> reslut = jdbcTemplate.query(sql, new DefaultRowMapper(WdPlanVo.class, getNameHandler()));
        return (List<WdPlanVo>)reslut;
    }
}
